﻿using System.Collections.Generic;
using System.Linq;
using Downloader.Domain;
using Downloader.Domain.Contracts.Tasks;
using SharpArch.Domain.PersistenceSupport;

namespace Downloader.Tasks
{
    public class ArticleContentTasks : IArticleContentTasks
    {

        private readonly IRepository<ArticleContent> articleRepository;
        public ArticleContentTasks(IRepository<ArticleContent> repository)
       {
           this.articleRepository = repository;
       }



       #region ICategoryTasks 成员

        public List<ArticleContent> GetAll()
       {
           return articleRepository.GetAll().OrderBy(c => c.CreateTime).ToList();
       }


        public ArticleContent Get(int id)
       {
           return articleRepository.Get(id);
       }

       public ArticleContent CreateOrUpdate(ArticleContent category)
       {
           return articleRepository.SaveOrUpdate(category);
       }

       public void Delete(int id)
       {
           var entity = articleRepository.Get(id);
           this.articleRepository.Delete(entity);
       }

       #endregion
    }
}
